<template>
  <div class="report-section" v-if="reportData">
    <!-- 报告头部 -->
    <div class="report-header">
      <h2>{{ examTypeName }} - 作文分析报告</h2>
      <div class="meta-info">
        <span class="exam-type">{{ examTypeName }}</span>
        <span class="eval-time" v-if="reportData.meta_info?.evaluation_time">
          {{ reportData.meta_info.evaluation_time }}
        </span>
        <span class="word-count" v-if="reportData.meta_info?.word_count">
          字数: {{ reportData.meta_info.word_count }}
        </span>
      </div>
    </div>

    <!-- 总体评估 -->
    <div class="overall-assessment" v-if="reportData.overall_assessment">
      <div class="score-cards">
        <div class="score-card primary">
          <div class="score-label">总分</div>
          <div class="score-value">{{ reportData.overall_assessment.total_score }}</div>
          <div class="score-grade">{{ reportData.overall_assessment.grade_level }}</div>
        </div>
        <div class="score-card">
          <div class="score-label">通过概率</div>
          <div class="score-value">{{ reportData.overall_assessment.pass_probability }}</div>
        </div>
        <div class="score-card">
          <div class="score-label">排名百分位</div>
          <div class="score-value">{{ reportData.overall_assessment.ranking_percentile }}</div>
        </div>
        <div class="score-card">
          <div class="score-label">提升潜力</div>
          <div class="score-value">{{ reportData.overall_assessment.improvement_potential }}</div>
        </div>
      </div>
    </div>

    <!-- 维度分析 -->
    <DimensionalAnalysis :dimensions="reportData.dimensional_analysis"
      :detailedStrengths="reportData.detailed_strengths" :detailedWeaknesses="reportData.detailed_weaknesses" />

    <!-- 可视化图表 -->
    <ChartSection :visualizationData="reportData.visualization_data" />

    <!-- 学习路径 -->
    <LearningRoadmap :roadmapData="reportData.learning_roadmap" />

    <!-- 专家点评 -->
    <div class="expert-commentary-section" v-if="reportData.expert_commentary">
      <h3>专家点评</h3>
      <div class="commentary-content">
        <p>{{ reportData.expert_commentary }}</p>
      </div>
      <div class="success-probability" v-if="reportData.success_probability">
        <div class="probability-item">
          <span class="label">当前通过率</span>
          <span class="value">{{ reportData.success_probability.current_level_pass }}</span>
        </div>
        <div class="probability-item">
          <span class="label">改进后通过率</span>
          <span class="value">{{ reportData.success_probability.with_improvement_pass }}</span>
        </div>
      </div>
    </div>
  </div>
</template>

<script>
import DimensionalAnalysis from './DimensionalAnalysis.vue';
import ChartSection from './ChartSection.vue';
import LearningRoadmap from './LearningRoadmap.vue';

export default {
  name: 'AnalysisReport',
  components: {
    DimensionalAnalysis,
    ChartSection,
    LearningRoadmap
  },
  props: {
    reportData: {
      type: Object,
      default: null
    },
    examTypeName: {
      type: String,
      default: '作文分析报告'
    }
  }
};
</script>

<style scoped>
.report-section {
  background: white;
  border-radius: 16px;
  padding: 30px;
  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.12);
  border: 1px solid rgba(58, 134, 255, 0.15);
}

.report-header {
  text-align: center;
  margin-bottom: 30px;
  padding-bottom: 20px;
  border-bottom: 2px solid #f0f0f0;
}

.report-header h2 {
  margin: 0 0 15px 0;
  color: #3a86ff;
  font-size: 1.8rem;
}

.meta-info {
  display: flex;
  justify-content: center;
  gap: 20px;
  flex-wrap: wrap;
  font-size: 0.9rem;
  color: #666;
}

.exam-type {
  background: #e3f2fd;
  color: #1976d2;
  padding: 4px 8px;
  border-radius: 4px;
  font-weight: 500;
}

.overall-assessment {
  margin-bottom: 40px;
}

.score-cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 20px;
}

.score-card {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: white;
  padding: 25px;
  border-radius: 12px;
  text-align: center;
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
}

.score-card.primary {
  background: linear-gradient(135deg, #3a86ff 0%, #8338ec 100%);
}

.score-label {
  font-size: 0.9rem;
  opacity: 0.9;
  margin-bottom: 8px;
  display: block;
}

.score-value {
  font-size: 2rem;
  font-weight: bold;
  display: block;
  margin-bottom: 5px;
}

.score-grade {
  font-size: 0.9rem;
  opacity: 0.8;
}

.expert-commentary-section {
  margin-top: 40px;
  padding: 25px;
  background: #f8f9fa;
  border-radius: 12px;
  border-left: 4px solid #28a745;
}

.expert-commentary-section h3 {
  color: #28a745;
  margin-bottom: 20px;
  font-size: 1.3rem;
}

.commentary-content {
  margin-bottom: 20px;
  line-height: 1.6;
  color: #333;
}

.success-probability {
  display: flex;
  gap: 30px;
  flex-wrap: wrap;
}

.probability-item {
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.probability-item .label {
  font-size: 0.9rem;
  color: #666;
}

.probability-item .value {
  font-size: 1.2rem;
  font-weight: bold;
  color: #28a745;
}
</style>